package org.datacoder.geocoding.datastructures.geoshapes

import com.vividsolutions.jts.geom.*
import com.vividsolutions.jts.geom.impl.*
import org.datacoder.geocoding.*

/**
 * The bottom edge of the bounding rectangle of
 * a jurisdiction.
 */
class GeoHzInterval extends GeoInterval {

    public double lon1
    public double lon2
    public double lat

    public double retrieveSingleValue(){
        return lat
    }
    public double retrieveMinDoubleValue(){
        return lon1
    }
    public double retrieveMaxDoubleValue(){
        return lon2
    }

    public boolean intersectsGeoVtInterval(GeoVtInterval gvi){
        if((lon1 <= gvi.lon) && (gvi.lon <= lon2) &&
            (gvi.lat1 <= lat) && (lat <= gvi.lat2)){
            return true
        }else{
            return false
        }
    }

    public Geometry toGeometry(){
        Coordinate[] endPoints = new Coordinate[2]
        endPoints[0] = new Coordinate(lon1, lat)
        endPoints[1] = new Coordinate(lon2, lat)
        LineString lineString = new LineString(
            new CoordinateArraySequence(endPoints),
            GeocodingUtils.geometryFactory
        )
        return lineString
    }

}

